import QtQuick 2.0
import QtQuick.Shapes 1.14
import QtGraphicalEffects 1.14
import QtQuick.Extras 1.4
import Qt.labs.platform 1.1
import QtQuick.Controls 2.14
import QtQuick 2.14
import QtQuick.Layouts 1.14



Item {
    id:root
    implicitHeight:1024
    implicitWidth: 600

    signal quit()
    signal refresh()
    property alias wifiSource: wifi.source
    property alias urlSource : url.source


    Rectangle{
        width: 1024
        height: 600
        anchors.leftMargin: 0
        color: "transparent"
        z:0
        Rectangle{
            z:1
            width: 680
            height: 385
            anchors.rightMargin: 105
            anchors.verticalCenter: parent.verticalCenter
            radius: 10
            color: "#ffffff"
            MouseArea{
                anchors.fill: parent
                // propagateComposedEvents: true
                onPressed: mouse.accepted = true;
                onReleased: mouse.accepted = true;
                onClicked: mouse.accepted = true;

            }
            // color:"red"
            ColumnLayout{
                // anchors.fill: parent
                anchors.top: parent.top
                anchors.horizontalCenter: parent.horizontalCenter
                width: parent.width
                spacing: 0
                Rectangle{
                    id:_refresh
                    width: 56
                    height: 56
                    color: "transparent"
                    Layout.alignment:Qt.AlignTop |Qt.AlignRight
                    Layout.topMargin: 0
                    Layout.rightMargin: 7
                    Layout.bottomMargin: 0
                    Image {
                        id: btn_refresh
                        source: "qrc:/img/refresh.png"
                        width: 40
                        height: 40
                        anchors.horizontalCenter: _refresh.horizontalCenter
                        anchors.verticalCenter: _refresh.verticalCenter
                    }
                    MouseArea{
                        anchors.fill: parent
                        onPressed: mouse.accepted = true
                        onClicked: mouse.accepted = true
                        onReleased: {
                            rotationAnim.running = true
                            root.refresh()
                            mouse.accepted = true
                        }
                    }
                }
                Rectangle{
                    // anchors.topMargin: 50
                    // anchors.horizontalCenter: parent.horizontalCenter
                    Layout.topMargin: 0
                    Layout.alignment:Qt.AlignHCenter
                    width: 531
                    height:275
                    color: "transparent"

                    RowLayout{
                        anchors.fill:  parent
                        spacing: 50
                        Rectangle{
                            width: 240
                            height:275
                            color: "transparent"

                            Image {
                                id: wifi
                                source: "qrc:/img/qrcode_hotspot.png"
                                width: 240
                                height:240
                                anchors.top: parent.top
                            }

                            Label{
                                anchors.horizontalCenter: parent.horizontalCenter
                                anchors.bottom: parent.bottom
                                // anchors.bottomMargin: 50
                                text: qsTr("扫二维码连接Wifi")
                                font{
                                    family: "Microsoft YaHei"
                                    pixelSize: 26
                                    bold: true
                                }
                                color: "#1989FA"
                            }
                        }

                        Rectangle{
                            width: 240
                            height:275
                            color: "transparent"
                            Image {
                                id: url
                                source: "qrc:/img/qrcode_url.png"
                                width: 240
                                height:240
                                anchors.top: parent.top
                            }

                            Label{
                                anchors.horizontalCenter: parent.horizontalCenter
                                anchors.bottom: parent.bottom
                                // anchors.bottomMargin: 50
                                text: qsTr("扫二维码上传文件")
                                font{
                                    family: "Microsoft YaHei"
                                    pixelSize: 26
                                    bold: true
                                }
                                color: "#1989FA"
                            }
                        }

                    }
                }
            }

        }
        MouseArea{
            anchors.fill:  parent
            onPressed: mouse.accepted = true
            onClicked: mouse.accepted = true

            onReleased: {
                // mouse.accepted = false
                root.quit()
                // console.log("Large MouseArea clicked!")
                // 阻止事件传播到 smallMouseArea
                mouse.accepted = true
            }
        }
    }

    RotationAnimation {
       id: rotationAnim
       target: btn_refresh
       property: "rotation"
       from: 360
       to: 0
       duration: 500 //500 ms
       running: false
       loops: 1
    }

}





